package com.android.nexttbi;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

public class DetalheFilial extends Activity {
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        //requestWindowFeature(Window.FEATURE_PROGRESS);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.addressbook); 
        
        TextView txtDesc = (TextView)findViewById(R.id.txtDescricao);
        //TextView txtGerente = (TextView)findViewById(R.id.txtGerente);
        TextView txtEmail = (TextView)findViewById(R.id.txtEmail);
        TextView txtTelefone = (TextView)findViewById(R.id.txtTelefone);
        
        
        Intent intent = getIntent();
        final String telefone = intent.getStringExtra("telefone");
        final String email = intent.getStringExtra("email");
        txtDesc.setText(intent.getStringExtra("descricao"));
        //txtGerente.setText("Gerente: " +intent.getStringExtra("gerente"));
        txtEmail.setText("E-mail: " + email);
        txtTelefone.setText("Fone: " + telefone);
        
        
        
        ImageButton btCall = (ImageButton) findViewById(R.id.ibCall);
        
        btCall.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent chamada = new Intent(Intent.ACTION_DIAL);

                chamada.setData(Uri.parse("tel:" + telefone));

                startActivity(chamada);
				
				//ExibeMensagem(txtTelefone.getText().toString());
			}
		});
        
        ImageButton bEmail = (ImageButton) findViewById(R.id.ibEmail);
        //b.setOnClickListener(this);
        bEmail.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				
				String[] recipients = new String[]{email}; 
				
				
				Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
				emailIntent.setType("text/html");
				emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
				startActivity(Intent.createChooser(emailIntent, "Enviar email..."));

				//ExibeMensagem(txtEmail.getText().toString());
			}
		});
        
        ImageButton bVoltar = (ImageButton) findViewById(R.id.ibVoltar);
        //b.setOnClickListener(this);
        bVoltar.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				finish();
			}
		});
    }
	
	private void ExibeMensagem(String msg){
    	Toast.makeText(getApplicationContext(),
			    msg, Toast.LENGTH_SHORT).show();
    }

}
